<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="resource/css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="./resource/fonts/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="resource/css/jedate.css"/>
		<link rel="stylesheet" type="text/css" href="resource/css/common.css"/>
	</head>
	<body>
		<div class="container-fluid">
			<div class="row mheader">
				<div class="col-xs-2 text-left"><a href="javascript:;" onclick="javascript:history.back(-1);"><span class="iconfont icon-fanhui"></span></a></div>
				<div class="col-xs-8"><h2>修改密码</h2></div>
				<div class="col-xs-2"></div>
			</div>
			<div class="row">
				<div class="com-form ">
					<form class="form-horizontal">
						<div class="form-group">
					    	<label class="col-xs-3 control-label" for="">旧密码:</label>
					    	<div class="col-xs-9">
					    		<input type="text" class="form-control" id="jmm" placeholder="" value="">
							</div>
						</div>
						<div class="form-group">
					    	<label class="col-xs-3 control-label" for="">新密码:</label>
					    	<div class="col-xs-9">
					    		<input type="text" class="form-control" id="xmm" placeholder="" value="">
							</div>
						</div>
						<div class="form-group">
					    	<label class="col-xs-3 control-label" for="" onblur="yz()" >确认密码:</label>
					    	<div class="col-xs-9">
					    		<input type="text" class="form-control" id="qmm" placeholder="" value="">
							</div>
						</div>
					  	<div class="form-group">
					    	<label class="col-xs-3 control-label" for="">&nbsp;</label>
					    	<div class="col-xs-9">
					    		<button type="button" class="btn btn-info btn-block">保存</button>
					    	</div>
					  	</div>
					  	
					 </form>
				</div>
			
			</div>
		</div>
	</body>
</html>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="resource/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="./resource/js/style.js"></script>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script>

	function yz() {
		var jm = $("#xmm").val();
		var xm = $("#xmm").val();
		if ( jm != xm ){
		    window.tool.alert("新密码与确认密码输入不一致");
		}
    }

    /**
     * 	退出
     */
    function exitlogin() {
        var ids=getCookie('yanzheng');
        var id=ids.split('|');
        var can=id[4];
        ajaxs("api/app/logout.do",
            'post',
            {'token':can },
            function (data) {
                console.log(data)
            }
        );
        delCookie("yanzheng");
        location.href='./login.html';
        //退出处理缓存
        window.tool.exit();
        window.tool.clearCache();
    }

    /**
     * 	清缓存
     */
    function clearCache() {
        //app端生效
        window.tool.clearCache();
    }




	$(function(){
	    var name = $(".u-name");
	    if ( getP() ){
			var arr = getP().split("|");
	        $(name).text(arr[0]);
		} else {
			$(name).html('<a href="login.html" >立即登录</a>');
			$("eBtn").remove();
		};
		var mmYZ='^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$';

        var arr = getP().split("|");
       	arr=arr[2];
		$('.btn').click(function () {
		    var	jmm=$('#jmm').val();		//旧密码
			var xmm=$('#xmm').val();		//新密码
            var qmm=$('#qmm').val();		//确认密码
			if(jmm==xmm){
                window.tool.alert('新密码不能和旧密码相同');
				return;
            }
			if(xmm!=qmm){
                window.tool.alert('两次输入的密码不一致');
                return;
			}
			ajaxs('api/user/upPwd.do','post',{'opid':arr,'oldPwd':jmm,'pwd':qmm},function (data) {
				if(data.code==0){
                    exitlogin();
                    window.tool.alert(data.msg);
                }else {
                    window.tool.alert(data.msg);
				}
            })
        })



	});



</script>







